<?php
/**
 * Created by PhpStorm.
 * User: change
 * Date: 2017/2/4
 * Time: 17:56
 * 化验类型
 */

namespace Admin\Controller;


use Admin\Model\BaseinfoVersionModel;
use Base\Controller\CurdController;
use Library\Utils;

class DailyiteminfoController extends CurdController
{
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * 获取所有数据并注入模板
     * */
    protected function getAll()
    {
        if($_REQUEST['keyword']){
            $map['name'] = array('like','%'.$_REQUEST['keyword'].'%');
            $map['name_en']  = array('like', '%'.$_REQUEST['keyword'].'%');
            $map['_logic'] = 'or';
            $where['_complex'] = $map;
        }
        if(!I('get.del')){
            $where['status']=1;
        }else{
            $where['status']=0;
        }
       if($_REQUEST['selects']){
            $limit=$_REQUEST['selects'];
        }else{
            $limit=20;
        }
        $data = $this->model->pageToView($limit, true,$where);
        $this->assign("page", $data['page']);
        $this->assign("list", $data['list']);
    }
    protected function addAfter($data)
    {
        $BaseinfoVersionModel=new BaseinfoVersionModel();
        $controller = hump2underline(CONTROLLER_NAME);
        $infos=$BaseinfoVersionModel->where(array('name'=>$controller))->find();
        $data['version']=$infos['version'];
        $ids=$this->model->order('id desc')->find();
        $data['id']=$ids['id']+1;
        return $data;
    }
    protected function editAfter($data)
    {
        $BaseinfoVersionModel=new BaseinfoVersionModel();
        $controller = hump2underline(CONTROLLER_NAME);
        $infos=$BaseinfoVersionModel->where(array('name'=>$controller))->find();
        $data['version']=$infos['version'];
        return $data;
    }
}